/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
osThreadId SDK_RunHandle;
osThreadId Ser_HandleHandle;
osThreadId Screen_HanleHandle;
osThreadId Vel_CrtHandle;
osThreadId StartU2Handle;
osThreadId startU4Handle;
osThreadId startU1Handle;
osThreadId StartU5Handle;
osThreadId StartU6Handle;

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void SDK_Run_Task(void const * argument);
void Ser_Handle_Task(void const * argument);
void Screen_Hanle_Task(void const * argument);
void Vel_Crt_Handle(void const * argument);
void StartU2Task(void const * argument);
void StartU4Task(void const * argument);
void StartU1Task(void const * argument);
void StartU5Task(void const * argument);
void StartU6Task(void const * argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );

/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];

void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
{
  *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  *ppxIdleTaskStackBuffer = &xIdleStack[0];
  *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  /* place for user code */
}
/* USER CODE END GET_IDLE_TASK_MEMORY */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* definition and creation of SDK_Run */
  osThreadDef(SDK_Run, SDK_Run_Task, osPriorityAboveNormal, 0, 512);
  SDK_RunHandle = osThreadCreate(osThread(SDK_Run), NULL);

  /* definition and creation of Ser_Handle */
  osThreadDef(Ser_Handle, Ser_Handle_Task, osPriorityAboveNormal, 0, 512);
  Ser_HandleHandle = osThreadCreate(osThread(Ser_Handle), NULL);

  /* definition and creation of Screen_Hanle */
  osThreadDef(Screen_Hanle, Screen_Hanle_Task, osPriorityAboveNormal, 0, 512);
  Screen_HanleHandle = osThreadCreate(osThread(Screen_Hanle), NULL);

  /* definition and creation of Vel_Crt */
  osThreadDef(Vel_Crt, Vel_Crt_Handle, osPriorityHigh, 0, 512);
  Vel_CrtHandle = osThreadCreate(osThread(Vel_Crt), NULL);

  /* definition and creation of StartU2 */
  osThreadDef(StartU2, StartU2Task, osPriorityAboveNormal, 0, 512);
  StartU2Handle = osThreadCreate(osThread(StartU2), NULL);

  /* definition and creation of startU4 */
  osThreadDef(startU4, StartU4Task, osPriorityAboveNormal, 0, 512);
  startU4Handle = osThreadCreate(osThread(startU4), NULL);

  /* definition and creation of startU1 */
  osThreadDef(startU1, StartU1Task, osPriorityAboveNormal, 0, 512);
  startU1Handle = osThreadCreate(osThread(startU1), NULL);

  /* definition and creation of StartU5 */
  osThreadDef(StartU5, StartU5Task, osPriorityAboveNormal, 0, 512);
  StartU5Handle = osThreadCreate(osThread(StartU5), NULL);

  /* definition and creation of StartU6 */
  osThreadDef(StartU6, StartU6Task, osPriorityNormal, 0, 1024);
  StartU6Handle = osThreadCreate(osThread(StartU6), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

}

/* USER CODE BEGIN Header_SDK_Run_Task */
/**
  * @brief  Function implementing the SDK_Run thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_SDK_Run_Task */
__weak void SDK_Run_Task(void const * argument)
{
  /* USER CODE BEGIN SDK_Run_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END SDK_Run_Task */
}

/* USER CODE BEGIN Header_Ser_Handle_Task */
/**
* @brief Function implementing the Ser_Handle thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_Ser_Handle_Task */
__weak void Ser_Handle_Task(void const * argument)
{
  /* USER CODE BEGIN Ser_Handle_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END Ser_Handle_Task */
}

/* USER CODE BEGIN Header_Screen_Hanle_Task */
/**
* @brief Function implementing the Screen_Hanle thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_Screen_Hanle_Task */
__weak void Screen_Hanle_Task(void const * argument)
{
  /* USER CODE BEGIN Screen_Hanle_Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END Screen_Hanle_Task */
}

/* USER CODE BEGIN Header_Vel_Crt_Handle */
/**
* @brief Function implementing the Vel_Crt thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_Vel_Crt_Handle */
__weak void Vel_Crt_Handle(void const * argument)
{
  /* USER CODE BEGIN Vel_Crt_Handle */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END Vel_Crt_Handle */
}

/* USER CODE BEGIN Header_StartU2Task */
/**
* @brief Function implementing the StartU2 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU2Task */
__weak void StartU2Task(void const * argument)
{
  /* USER CODE BEGIN StartU2Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU2Task */
}

/* USER CODE BEGIN Header_StartU4Task */
/**
* @brief Function implementing the startU4 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU4Task */
__weak void StartU4Task(void const * argument)
{
  /* USER CODE BEGIN StartU4Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU4Task */
}

/* USER CODE BEGIN Header_StartU1Task */
/**
* @brief Function implementing the startU1 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU1Task */
__weak void StartU1Task(void const * argument)
{
  /* USER CODE BEGIN StartU1Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU1Task */
}

/* USER CODE BEGIN Header_StartU5Task */
/**
* @brief Function implementing the StartU5 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU5Task */
__weak void StartU5Task(void const * argument)
{
  /* USER CODE BEGIN StartU5Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU5Task */
}

/* USER CODE BEGIN Header_StartU6Task */
/**
* @brief Function implementing the StartU6 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU6Task */
__weak void StartU6Task(void const * argument)
{
  /* USER CODE BEGIN StartU6Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU6Task */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */
